/**
 * @file   MainWindow.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-03
 * @brief  DataBus Client Test Application Main Window.
 *
 * Copyright (C) 2013  Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtCore/QModelIndex>
#include <DataBus/Common/PropertyInfo.h>
#include "DataBusClientIdListModel.h"
#include "TestTcpClient.h"

namespace Ui
{
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    /**
     * @brief MainWindow constructor.
     *
     * @param parent    Parent
     */
    explicit MainWindow(QWidget *parent = 0);

    /**
     * @brief MainWindow destructor
     */
    ~MainWindow();

private slots:
    /**
     * @brief Start DataBus Client
     */
    void startClient();

    /**
     * @brief Stop DataBus Client
     */
    void stopClient();

    /**
     * @brief Execute when client registered signal is emitted
     *
     * @param status    Success (true) or Error (false)
     */
    void clientRegistered(bool status);

    /**
     * @brief Execute when stopped signal is emitted
     */
    void clientStopped();

    /**
     * @brief Process Received Packet
     */
    void processReceivedPacket(DataBus::Packet packet);

    /**
     * @brief Start reading Client List
     */
    void readClientList();

    /**
     * @brief Start reading selected Client Info
     */
    void readClientInfo();

private:
    /**
     * @brief GUI component
     */
    Ui::MainWindow *ui;

    /**
     * @brief DataBus Client
     */
    TestTcpClient m_dataBusClient;

    /**
     * @brief Registered Client ID List Model
     */
    DataBusClientIdListModel m_registeredClientIdListModel;

    /**
     * @brief Selected Client ID
     */
    quint8 m_selectedClientId;

    /**
     * @brief Selected Client Name
     */
    QString m_selectedClientName;

    /**
     * @brief Selected Client Status
     */
    DataBus::ClientStatus m_selectedClientStatus;

    /**
     * @brief Pending Property Id List
     */
    QList<quint8> m_pendingPropertyIdList;

    /**
     * @brief Selected Client Property List
     */
    QList<DataBus::PropertyInfo> m_selectedClientPropertyList;
};

#endif // MAINWINDOW_H
